package com.ruoyi.oa.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.oa.domain.OaEmployees;
import com.ruoyi.oa.service.IOaEmployeesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工功能Controller
 * 
 * @author ruoyi
 * @date 2024-12-28
 */
@RestController
@RequestMapping("/oa/employees")
public class OaEmployeesController extends BaseController
{
    @Autowired
    private IOaEmployeesService oaEmployeesService;

    /**
     * 查询员工功能列表
     */
    @PreAuthorize("@ss.hasPermi('oa:employees:list')")
    @GetMapping("/list")
    public TableDataInfo list(OaEmployees oaEmployees)
    {
        startPage();
        List<OaEmployees> list = oaEmployeesService.selectOaEmployeesList(oaEmployees);
        return getDataTable(list);
    }

    /**
     * 导出员工功能列表
     */
    @PreAuthorize("@ss.hasPermi('oa:employees:export')")
    @Log(title = "员工功能", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OaEmployees oaEmployees)
    {
        List<OaEmployees> list = oaEmployeesService.selectOaEmployeesList(oaEmployees);
        ExcelUtil<OaEmployees> util = new ExcelUtil<OaEmployees>(OaEmployees.class);
        util.exportExcel(response, list, "员工功能数据");
    }

    /**
     * 获取员工功能详细信息
     */
    @PreAuthorize("@ss.hasPermi('oa:employees:query')")
    @GetMapping(value = "/{oaEmployeeId}")
    public AjaxResult getInfo(@PathVariable("oaEmployeeId") Long oaEmployeeId)
    {
        return success(oaEmployeesService.selectOaEmployeesByOaEmployeeId(oaEmployeeId));
    }

    /**
     * 新增员工功能
     */
    @PreAuthorize("@ss.hasPermi('oa:employees:add')")
    @Log(title = "员工功能", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OaEmployees oaEmployees)
    {
        return toAjax(oaEmployeesService.insertOaEmployees(oaEmployees));
    }

    /**
     * 修改员工功能
     */
    @PreAuthorize("@ss.hasPermi('oa:employees:edit')")
    @Log(title = "员工功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OaEmployees oaEmployees)
    {
        return toAjax(oaEmployeesService.updateOaEmployees(oaEmployees));
    }

    /**
     * 删除员工功能
     */
    @PreAuthorize("@ss.hasPermi('oa:employees:remove')")
    @Log(title = "员工功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{oaEmployeeIds}")
    public AjaxResult remove(@PathVariable Long[] oaEmployeeIds)
    {
        return toAjax(oaEmployeesService.deleteOaEmployeesByOaEmployeeIds(oaEmployeeIds));
    }
}
